<template>
	<el-form :model="editForm" label-width="80" :rules="editFormRules" ref="editForm" label-position="left">
		<el-row>
			<el-col :span="6">
 					<el-form-item label="归属项目" prop="projectId">
						{{ editForm.projectId }}
					</el-form-item>
					<el-form-item label="归属产品" prop="productId">
						<span v-if="editForm.productId">{{ editForm.productId }}</span>
						<span v-if="!xmProductCpd || !xmProductCpd.id">
							<xm-product-select ref="xmProductSelect1" 
								:link-project-id="selProject ? selProject.id : null" @change2="onProductSelected"
								@clear="onProductClearSelect" />
						</span>
					</el-form-item>
					<span v-if="editForm.productId">
						<el-form-item label="关联用例" prop="caseId">
							<span>{{ editForm.caseName ? editForm.caseName : '无' }} <el-button type="text"
									@click="caseVisible = true">选择用例</el-button></span>
						</el-form-item>
						<el-form-item label="归属模块" prop="funcId">
							<span>{{ editForm.funcName ? editForm.funcName : '无' }} <el-button type="text"
									@click="funcVisible = true">选择模块</el-button></span>
						</el-form-item>
						<el-form-item label="归属需求" prop="menuId">
							<el-tag title="隶属需求" style="width:100%;" closable @click="showSelectMenu" @close.stop="handleCloseMenuTag">
								<div class="icon" :style="{ backgroundColor: 'rgb(79, 140, 255)' }">
									<i :class="'document'"></i>
								</div> {{ editForm.menuName ? editForm.menuName : "未关联需求" }}
							</el-tag>
						</el-form-item>
					</span> 

 					<el-form-item label="最新意见" prop="remarks" class="field">
						<div>{{ editForm.remarks || '暂无最新意见' }}</div>
					</el-form-item>
					<el-form-item label="我的意见" prop="remarks2" class="field">
						<mdp-input type="textarea" :rows="3" v-model="editForm.remarks2" placeholder="处理意见"
							@change="editSomeFields(editForm, 'remarks', $event)" />
					</el-form-item>
 			</el-col>
			<el-col :span="18" class="border padding">

				<el-form-item label="缺陷标题" prop="name">
					<el-input v-model="editForm.name" placeholder="缺陷标题"
						@change="editSomeFields(editForm, 'name', $event)" />
					<span v-if="subOpType !== 'add'">
						<span class="label-font-color">缺陷编号：{{ editForm.id }} </span>
						<el-divider direction="vertical" />
						<span class="label-font-color">{{ editForm.createUsername }} 于 {{ editForm.createTime }} 创建 </span>
						<el-divider direction="vertical" />
						<el-tag v-if="editForm.tagNames">{{ editForm.tagNames ? editForm.tagNames : '' }} </el-tag>
						<el-button type="text" icon="plus" @click="tagSelectVisible = true">标签</el-button>
						<el-divider direction="vertical" />
						<el-button type="text" icon="share" @click="copyLink">分享</el-button>
					</span>
				</el-form-item>
				<el-row>
					<el-col :span="6">
						<el-form-item>
							<mdp-select-user show-style="x" size="medium" label="责任人" v-model="editForm.handlerUserid" :init-name="editForm.handlerUsername"
								@change="editSomeFields(editForm, 'handlerUserid', $event)">
								<template #extOpe>
									指派给 <el-button type="text" @click="sendToAsk"> 提出人</el-button> <el-button type="text"
										@click="sendToCreater"> 创建人</el-button>
								</template>
							</mdp-select-user>
						</el-form-item>

					</el-col>

					<el-col :span="6">
						<el-form-item>
							<mdp-select show-style="x" size="medium" label="状态" item-code="bugStatus" v-model="editForm.bugStatus"
								@change="editSomeFields(editForm, 'bugStatus', $event)" />
						</el-form-item>
					</el-col>

					<el-col :span="6">
						<el-form-item>
							<mdp-select show-style="x" size="medium" label="优先级" item-code="priority" v-model="editForm.priority"
								@change="editSomeFields(editForm, 'priority', $event)" />
						</el-form-item>
					</el-col>

					<el-col :span="6">
						<el-form-item>
							<mdp-date show-style="x" size="medium" label="结束时间" value-format="YYYY-MM-DD HH:mm:ss"
								v-model="editForm.endTime" @change="editSomeFields(editForm, 'endTime', $event)" />
						</el-form-item>
					</el-col>
				</el-row>
				<el-tabs v-model="activateTabPaneName" ref="editRef">

					<el-tab-pane label="缺陷描述" name="12">
						<el-form-item label="" prop="description" label-width="0px">
							<vue-editor :height="250"  
								class="rich-context" :id="'description_' + editForm.id" :branch-id="userInfo.branchId"
								v-model="editForm.description" />
						</el-form-item>
						<el-row style="float:right;" v-if="subOpType !== 'add'">
							<el-button @click="handleCancel">取消</el-button>
							<el-button v-loading="load.edit" v-if="editForm.description !== dataBak.description" type="primary"
								@click="editSomeFields(editForm, 'description', editForm.description)"
								:disabled="load.edit == true">保存</el-button>
						</el-row>
					</el-tab-pane>
					<el-tab-pane name="1" label="基本信息">
						<el-row>

							<el-col :span="8">
								<el-form-item label="提出人" prop="askUsername">
									<mdp-select-user show-style="tag" label="提出人" v-model="editForm.askUserid"
										:init-name="editForm.askUsername" @change2="editSomeFields(editForm, 'askUserid', $event)" />
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="复现频率" prop="repRate">
									<mdp-select show-style="tag" item-code="bugRepRate" v-model="editForm.repRate"
										@change="editSomeFields(editForm, 'repRate', $event)" />
								</el-form-item>

							</el-col>
							<el-col :span="8">
								<el-form-item label="复现版本" prop="verNum">
									<el-input v-model="editForm.verNum" placeholder="请填写版本号"
										@change="editSomeFields(editForm, 'verNum', $event)" />
								</el-form-item>
							</el-col>
						</el-row>
						<el-row>

							<el-col :span="8">
								<el-form-item label="严重程度" prop="bugSeverity">
									<mdp-select show-style="tag" item-code="bugSeverity" v-model="editForm.bugSeverity"
										@change="editSomeFields(editForm, 'bugSeverity', $event)" />

								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="原因分析" prop="bugReason">
									<mdp-select show-style="tag" item-code="bugReason" v-model="editForm.bugReason"
										@change="editSomeFields(editForm, 'bugReason', $event)" />

								</el-form-item>
							</el-col>

							<el-col :span="8">
								<el-form-item label="解决方案" prop="solution">
									<mdp-select show-style="tag" item-code="bugSolution" v-model="editForm.solution"
										@change="editSomeFields(editForm, 'solution', $event)" />

								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="缺陷类别" prop="bugType">
									<mdp-select show-style="tag" item-code="bugType" v-model="editForm.bugType"
										@change="editSomeFields(editForm, 'bugType', $event)" />

								</el-form-item>

							</el-col>
						</el-row>
					</el-tab-pane>

					<el-tab-pane label="测试步骤" name="2">
 							<test-step-result v-model="editForm.opStep" v-if="stepConfigVisible == false"/> 
 							<test-step-config v-model="editForm.opStep" v-if="stepConfigVisible == true"/>
 						<el-space wrap>
							&nbsp;&nbsp;<el-button @click="handleCancel">取消</el-button>
							<el-button @click="stepConfigVisible = !stepConfigVisible">{{ stepConfigVisible ? '完成步骤配置' : '去配置步骤' }}</el-button>
							<el-button v-loading="load.edit" v-if="editForm.opStep != dataBak.opStep" type="primary"
								@click="editSomeFields(editForm, 'opStep', editForm.opStep)"
								:disabled="load.edit == true">保存</el-button>
						</el-space>
					</el-tab-pane>


					<el-tab-pane
						:label="'工时( ' + (editForm.actWorkload ? editForm.actWorkload : 0) + ' / ' + (editForm.budgetWorkload ? editForm.budgetWorkload : 0) + ' h )'"
						name="55">
						<xm-workload-record v-if="activateTabPaneName == '55'" biz-type="2" :xm-question="editForm" />
					</el-tab-pane>
					<el-tab-pane label="流转记录" name="4" v-if="subOpType != 'add'">
						<xm-question-handle-mng v-if="activateTabPaneName == '4'" :bug="editForm" :visible="activateTabPaneName == '4'" />
					</el-tab-pane>
					<el-tab-pane label="关注" name="91" v-if="subOpType != 'add'">
						<MdpFocus v-if="activateTabPaneName == '91'" :biz-id="editForm.id" :pbiz-id="editForm.projectId"
							:biz-name="editForm.name" focus-type="5" />
					</el-tab-pane>



				</el-tabs>
			</el-col>

		</el-row>
		<el-row class="footer" v-if="subOpType === 'add'">
			<el-button type="primary" @click="saveSubmit">保存</el-button>
		</el-row>
	</el-form>

	<mdp-dialog append-to-body title="需求选择" v-model="selectMenuVisible" width="90%" :close-on-click-modal="false">
		<xm-menu-list v-if="selectMenuVisible"
			:xm-product="editForm.productId ? { id: editForm.productId, productName: editForm.productName } : xmProductCpd"
			:xm-iteration="xmIteration" :visible="selectMenuVisible"
			@select="onSelectedMenu" :sel-project="selProject" />
	</mdp-dialog>
	<mdp-dialog append-to-body title="标签" v-model="tagSelectVisible" class="dialog-body" width="60%">
		<MdpSelectTag v-model="editForm.tagIds" multiple @change2="editSomeFields(editForm, 'tagIds', $event)"/>
	</mdp-dialog>

	<mdp-dialog append-to-body title="模块选择" v-model="funcVisible" size="40%" top="20px" :close-on-click-modal="false">
		<xm-func-select subOpType="select" showConfirm class="padding-left padding-right" v-if="funcVisible" @select="onFuncSelected"
			:xm-product="editForm.productId ? { id: editForm.productId, productName: editForm.productName } : xmProductCpd" />
	</mdp-dialog>

	<mdp-dialog append-to-body title="执行用例选择" v-model="caseVisible" width="80%" top="20px" :close-on-click-modal="false">
		<xm-test-plan-case-mng v-if="caseVisible" :select="true" :visible="caseVisible"
			:xm-project="selProject && selProject.id ? selProject : (editForm.projectId ? { id: editForm.projectId } : null)"
			:xm-test-plan="xmTestPlan"
			:xm-product="editForm.productId ? { id: editForm.productId, productName: editForm.productName } : xmProductCpd"
			@select="onTestPlanCaseSelected" />
	</mdp-dialog>
</template>

<script>
import util from '@/components/mdp-ui/js/util';//全局公共库

import { addXmQuestion, editXmQuestion, editXmQuestionSomeFields } from '@/api/xm/core/xmQuestion';
import { mapState } from 'pinia'
import { useUserStore } from '@/store/modules/user';
import { sn } from '@/components/mdp-ui/js/sequence';
//import { Editor as VueEditor } from '@/components/Editor'

import { Editor as VueEditor } from '@/components/Editor'
import XmMenuList from '../xmMenu/XmMenuList.vue';
import XmQuestionHandleMng from '../xmQuestionHandle/XmQuestionHandleMng.vue';//修改界面
import clipboard3 from 'vue-clipboard3'
const { toClipboard } = clipboard3();

import XmFuncSelect from '../xmFunc/XmFuncSelect.vue'

import TestStepConfig from '../xmTestCase/TestStepConfig.vue';
import TestStepResult from '../xmTestPlanCase/TestStepResult.vue';
import XmProductSelect from '@/views/xm/core/components/XmProductSelect.vue' 
import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin';
import { defineAsyncComponent } from 'vue';
export default {
	mixins:[MdpFormMixin],
	computed: {
		...mapState(useUserStore, [
			'userInfo', 'roles'
		]),

		calcBugStep() {
			if (this.dicts['bugStatus'] && this.editForm) {
				var index = this.dicts['bugStatus'].findIndex(i => {
					if (i.id == this.editForm.bugStatus) {
						return true;
					} else {
						return false;
					}
				})
				return index + 1;
			} else {
				return 0;
			}

		},
		xmProductCpd() {
			if (this.xmQuestion && this.xmQuestion.id && this.xmQuestion.productId) {
				return { id: this.xmQuestion.productId, productName: this.xmQuestion.productName }
			}
			if (this.xmProduct && this.xmProduct.id) {
				return this.xmProduct
			}
			if (this.xmTestPlan && this.xmTestPlan.id) {
				return { id: this.xmTestPlan.productId, productName: this.xmTestPlan.productName }
			}
			if (this.xmTestPlanCase && this.xmTestPlanCase.id && this.xmTestPlanCase.productId) {
				return { id: this.xmTestPlanCase.productId, productName: this.xmTestPlanCase.productName }
			}
			if (this.xmTestCase && this.xmTestCase.id) {
				return { id: this.xmTestCase.productId, productName: this.xmTestCase.productName }
			}
			if (this.xmMenu && this.xmMenu.menuId) {
				return { id: this.xmMenu.productId, productName: this.xmMenu.productName }
			}

			if (this.xmIteration && this.xmIteration.id) {
				return { id: this.xmIteration.productId, productName: this.xmIteration.productName }
			}
			return null
		}
	},
	props: ['xmQuestion', 'visible', "selProject", 'subOpType', 'xmProduct', 'xmTestCase', 'xmTestPlanCase', 'xmMenu', 'xmIteration', 'xmTestPlan'],
	watch: {
		'xmQuestion': function (xmQuestion) {
			this.editForm = { ...xmQuestion };
		},
		'visible': function (visible) {
			if (visible == true) {
				this.initData();
			}
			this.activateTabPaneName = '12'
		}
	},
	data() {
		return {
			currOpType:'add',
			dicts: {
				priority: [],
				bugSeverity: [],
				bugSolution: [],
				bugStatus: [],
				bugType: [],
				bugRepRate: [],
				bugReason: [],
			},//下拉选择框的所有静态数据  params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
			load: { list: false, edit: false, del: false, add: false },//查询中...
			editFormRules: {
				name: [
					{ required: true, message: '缺陷标题不可为空', trigger: 'change' },
					{ min: 5, max: 250, message: '长度在 5 到 250 个字符', trigger: 'change' },//长度
				],
				askUsername: [
					{ required: true, message: '提出人不可为空', trigger: 'change' }
				],
				handlerUsername: [
					{ required: true, message: '请指派给一个人', trigger: 'change' }
				],
				description: [
					{ min: 0, max: 1000, message: '缺陷描述长度在 0 到 1000 个字符', trigger: 'change' },//长度
				],
				opStep: [
					{ min: 0, max: 1000, message: '测试步骤长度在 0 到 1000 个字符', trigger: 'change' },//长度
				],
				expectResult: [
					{ min: 0, max: 1000, message: '预期结果长度在 0 到 1000 个字符', trigger: 'change' },//长度
				],
				remarks: [
					{ min: 0, max: 1000, message: '处理意见长度在 0 到 1000 个字符', trigger: 'change' },//长度
				],

			},
			//新增界面数据 xm_question
			editForm: {
				id: '', name: '', projectId: '', projectName: '', caseId: '', caseName: '', endTime: '', askUserid: '', askUsername: '', handlerUserid: '', handlerUsername: '', priority: '', solution: '', description: '', createUserid: '', createUsername: '', createTime: '', bugStatus: '', bizProcInstId: '', bizFlowState: '', menuId: '', menuName: '', budgetWorkload: '', budgetAt: '', actWorkload: '', actAt: '', expectResult: '', opStep: '', currResult: '', refRequire: '', bugSeverity: '', bugType: '', tagIds: '', tagNames: '', urls: '', ltime: '', qtype: '', caseExecId: '', remarks: '', productId: '', repRate: '', verNum: '', vpath: '', pverNum: '', bugReason: '', rate: '', initWorkload: '', taskOut: '', taskId: '', funcId: '', funcName: '', funcPnames: '', planId: '', casedbId: '',
				attachment: [],
				productName: ''
			},
			//新增界面数据 xm_question
			editFormInit: {
				id: '', name: '', projectId: '', projectName: '', caseId: '', caseName: '', endTime: '', askUserid: '', askUsername: '', handlerUserid: '', handlerUsername: '', priority: '', solution: '', description: '', createUserid: '', createUsername: '', createTime: '', bugStatus: '', bizProcInstId: '', bizFlowState: '', menuId: '', menuName: '', budgetWorkload: '', budgetAt: '', actWorkload: '', actAt: '', expectResult: '', opStep: '', currResult: '', refRequire: '', bugSeverity: '', bugType: '', tagIds: '', tagNames: '', urls: '', ltime: '', qtype: '', caseExecId: '', remarks: '', productId: '', repRate: '', verNum: '', vpath: '', pverNum: '', bugReason: '', rate: '', initWorkload: '', taskOut: '', taskId: '', funcId: '', funcName: '', funcPnames: '', planId: '', casedbId: '',
				attachment: [],
				productName: ''
			}, 
			/**begin 在下面加自定义属性,记得补上面的一个逗号**/
			fileVisible: true,
			userFieldName: '',
			xmQuestionHandles: [],
			selectTaskVisible: false,
			selectMenuVisible: false,
			tagSelectVisible: false,
			xmProductVersions: [{ id: "1.0.0", name: '1.0.0' }],
			activateTabPaneName: '12',
			funcVisible: false,
			stepConfigVisible: false,
			caseVisible: false,
			maxTableHeight: 300,
			apis:{
				add: addXmQuestion,
				edit: editXmQuestion,
				editSomeFields: editXmQuestionSomeFields
			}
			/**end 在上面加自定义属性**/
		}//end return
	},//end data
	methods: { 
		//新增提交XmQuestion xm_question 父组件监听@submit="afterAddSubmit"
		preParamCheck: function ( params ) {

			if (this.xmIteration && this.xmIteration.id) {
				if (!this.editForm.menuId) {
					this.$notify({ position: 'bottom-left', showClose: true, message: '迭代视图中，新增缺陷必须关联需求，您可以通过设置【测试用例】或者【用户故事】达到关联需求目的。', type: 'error' });
					return;
				}
			}
			return true;
		},
		/**begin 在下面加自定义方法,记得补上面的一个逗号**/
		//上传附件
		onChange: function (file, fileList) {
			let list = [];
			if (fileList != null && fileList.length > 0) {
				fileList.forEach((item) => {
					let fileOne = {
						id: item.id,
						name: item.name,
						addr: item.url,
						type: item.fileSuffix,
						remark: item.remark,
					}
					list.push(fileOne);
				});
				this.editForm.attachment = list;
				console.log(list);
			}
		}, 
		handleQuestion: function (tardgetBugStatus) {
			this.editSubmit(tardgetBugStatus);
		},
		handleCloseTaskTag: function () {
			this.editForm.taskId = ''
			this.editForm.taskName = ""
		},
		sendToCreater() {
			this.editForm.handlerUsername = this.editForm.createUsername
			this.editForm.handlerUserid = this.editForm.createUserid
			this.editSomeFields(this.editForm, "handlerUserid", [{ userid: this.editForm.createUserid, username: this.editForm.createUsername }])

		},
		sendToAsk() {
			this.editForm.handlerUsername = this.editForm.askUsername
			this.editForm.handlerUserid = this.editForm.askUserid
			this.editSomeFields(this.editForm, "handlerUserid", [{ userid: this.editForm.askUserid, username: this.editForm.askUsername }])
		},
		/**end 在上面加自定义方法**/

		showSelectMenu: function () {
			if (this.selProject == null) {
				this.$notify({ position: 'bottom-left', showClose: true, message: "请先选项目", type: 'error' });
				return;
			}
			this.selectMenuVisible = true;
		},
		onSelectedMenu(menu) {
			if (menu.dclass < '3') {
				this.$notify({ position: 'bottom-left', showClose: true, message: "您选择的【" + menu.menuName + "】不属于用户故事,请重新选择。", type: 'error' });
				return;
			}
			this.editForm.menuId = menu.menuId
			this.editForm.menuName = menu.menuName
			this.editForm.productId = menu.productId
			this.selectMenuVisible = false;
			this.editSomeFields(this.editForm, 'menuId', menu)
		},
		handleCloseMenuTag: function () {
			this.editForm.menuId = ''
			this.editForm.menuName = ""
		},
		onTagSelected(tags) {
			this.tagSelectVisible = false;
			if (tags && tags.length > 0) {
				this.editForm.tagIds = tags.map(i => i.tagId).join(",")
				this.editForm.tagNames = tags.map(i => i.tagName).join(",")
			} else {
				this.editForm.tagIds = ""
				this.editForm.tagNames = ""
			}
		},

		onPorjectConfirm: function (project) {
			this.editForm.projectId = project.id
			this.editForm.projectName = project.name
		},
		clearProject() {
			this.editForm.projectId = ''
			this.editForm.projectName = ''
		},

		editSomeFieldsCheck(row, fieldName, $event,params) {  
			if (fieldName === 'handlerUserid') {
				if ($event) {
					params[fieldName] = $event.userid;
					params.handlerUsername = $event.username
				} else {
					return false;
				}
			} else if (fieldName === 'askUserid') {
				if ($event) {
					params[fieldName] = $event.userid;
					params.askUsername = $event.username
				} else {
					return false;
				}
			} else if (fieldName === 'tagIds') {
				if ($event) {
					params[fieldName] = $event.map(i => i.tagId).join(",");
					params.tagNames = $event.map(i => i.tagName).join(",");
				} else {
					return false;
				}
			} else if (fieldName === 'workload') {
				params = { ...params, ...$event }
			} else if (fieldName === 'projectId') {
				params.projectId = $event.id
				params.projectName = $event.name
			} else if (fieldName === 'productId') {
				params.productId = $event.id
			} else if (fieldName === 'menuId') {
				params.productId = $event.productId
				params.menuId = $event.menuId
				params.menuName = $event.menuName
				if ($event.funcId) {
					params.funcId = $event.funcId
					params.funcName = $event.funcName
				}
			} else if (fieldName === 'funcId') {
				params.productId = $event.productId
				params.funcId = $event.id
				params.funcName = $event.name
			} else if (fieldName === 'caseId') {
				params = Object.assign(params, $event)
			} else {
				params[fieldName] = $event
			} 
			return true;
		},
		copyLink() { 
			var curlDomain=window.location.protocol+"//"+window.location.host; //  
			var link = this.$mdp.getUri(curlDomain,import.meta.env.VITE_CONTEXT,import.meta.env.VITE_UI_VERSION,"/#/", "/#/xm/test/question/detail")+"?id=" + this.editForm.id
			toClipboard(link).then(e => {
				this.$notify({ position: 'bottom-left', showClose: true, message: "拷贝链接成功，您可以黏贴到任何地方", type: 'success' })
			});
		},
		onFuncSelected(row) {
			this.editForm.funcId = row.id
			this.editForm.funcName = row.name
			this.funcVisible = false;
			if (this.subOpType !== 'add') {
				this.editSomeFields(this.editForm, 'funcId', row)
			}
		},
		initCurrData() {
			this.currOpType=this.subOpType
			this.editForm = Object.assign(this.editForm, this.editFormInit)
			this.editForm = Object.assign(this.editForm, this.xmQuestion);
			if (this.subOpType === 'add') {
				this.editForm.askUserid = this.userInfo.userid
				this.editForm.askUsername = this.userInfo.username
				this.editForm.handlerUserid = this.userInfo.userid
				this.editForm.handlerUsername = this.userInfo.username
				this.editForm.bugReason = "0"
				this.editForm.bugReason = "0"
				this.editForm.qtype = "1"
				this.editForm.bugSeverity = "1"
				this.editForm.priority = "3"
				this.editForm.bugStatus = "0"
				if (this.selProject && this.selProject.id) {
					this.editForm.projectId = this.selProject.id
					this.editForm.projectName = this.selProject.name
				}
				if (this.xmProduct && this.xmProduct.id) {
					this.editForm.productId = this.xmProduct.id
					this.editForm.productName = this.xmProduct.productName
				}
				if (this.xmTestCase && this.xmTestCase.id) {
					this.editForm.productId = this.xmTestCase.productId
					this.editForm.productName = this.xmTestCase.productName
					this.editForm.caseId = this.xmTestCase.id
					this.editForm.caseName = this.xmTestCase.caseName
					this.editForm.casedbId = this.xmTestCase.casedbId
					this.editForm.funcId = this.xmTestCase.funcId
					this.editForm.funcName = this.xmTestCase.funcName
					this.editForm.menuId = this.xmTestCase.menuId
					this.editForm.menuName = this.xmTestCase.menuName
					this.editForm.opStep = this.xmTestCase.testStep
					this.editForm.name = this.xmTestCase.caseName
				}
				if (this.xmTestPlan && this.xmTestPlan.id) {
					this.editForm.casedbId = this.xmTestPlan.casedbId
					this.editForm.casedbName = this.xmTestPlan.casedbName
					this.editForm.planId = this.xmTestPlan.id
					this.editForm.projectId = this.xmTestPlan.projectId
					this.editForm.projectName = this.xmTestPlan.projectName
					this.editForm.productId = this.xmTestPlan.productId
					this.editForm.productName = this.xmTestPlan.productName
				}
				if (this.xmTestPlanCase && this.xmTestPlanCase.planId) {
					this.editForm.planId = this.xmTestPlanCase.planId
					this.editForm.productId = this.xmTestPlanCase.productId
					this.editForm.productName = this.xmTestPlanCase.productName
					this.editForm.caseId = this.xmTestPlanCase.caseId
					this.editForm.caseName = this.xmTestPlanCase.caseName
					this.editForm.casedbId = this.xmTestPlanCase.casedbId
					this.editForm.funcId = this.xmTestPlanCase.funcId
					this.editForm.funcName = this.xmTestPlanCase.funcName
					this.editForm.menuId = this.xmTestPlanCase.menuId
					this.editForm.menuName = this.xmTestPlanCase.menuName
					this.editForm.opStep = this.xmTestPlanCase.testStep
					this.editForm.name = this.xmTestPlanCase.caseName
					this.editForm.projectId = this.xmTestPlanCase.projectId
				}
				if (this.xmMenu && this.xmMenu.menuId) {
					this.editForm.menuId = this.xmMenu.menuId
					this.editForm.menuName = this.xmMenu.menuName
					if (this.xmMenu.productId) {
						this.editForm.productId = this.xmMenu.productId
						this.editForm.productName = this.xmMenu.productName
					}
					if (this.xmMenu.funcId) {
						this.editForm.funcId = this.xmMenu.funcId
						this.editForm.funcName = this.xmMenu.funcName
					}
				}
			} else {

			} 
		},
		onTestPlanCaseSelected(xmTestPlanCase) {
			var params = {};
			params.planId = xmTestPlanCase.planId
			params.productId = xmTestPlanCase.productId
			params.productName = xmTestPlanCase.productName
			params.caseId = xmTestPlanCase.caseId
			params.caseName = xmTestPlanCase.caseName
			params.casedbId = xmTestPlanCase.casedbId
			params.funcId = xmTestPlanCase.funcId
			params.funcName = xmTestPlanCase.funcName
			params.menuId = xmTestPlanCase.menuId
			params.menuName = xmTestPlanCase.menuName
			if (!this.editForm.opStep) {
				params.opStep = xmTestPlanCase.testStep
			}
			if (!this.editForm.name) {
				params.name = xmTestPlanCase.caseName
			}

			params.projectId = xmTestPlanCase.projectId
			Object.assign(this.editForm, params)
			this.editSomeFields(this.editForm, "caseId", params)
			this.caseVisible = false;
		},
		onProductSelected(product) {
			this.editForm.productId = product.id
			this.editForm.productName = product.productName
			if (this.subOpType != 'add') {
				this.editSomeFields(this.editForm, 'productId', product);
			}
		},
		onProductClearSelect() {
			this.editForm.productId = ""
			this.editForm.productName = ""
		}
	},//end method
	components: {
		//在下面添加其它组件 'xm-question-edit':XmQuestionEdit
		VueEditor, XmMenuList, XmQuestionHandleMng, XmProductSelect,
		XmFuncSelect, TestStepConfig, TestStepResult,
		xmTestPlanCaseMng: defineAsyncComponent(() => import('../xmTestPlanCase/XmTestPlanCaseSelect.vue')),
		'xm-workload-record': defineAsyncComponent(() => import("../xmWorkload/XmWorkloadRecord.vue")),
	}, 
}

</script>

<style lang="scss" scoped>.wf-main-context-box {
	border: 1px dashed #000;
	padding: 10px;
}

.wf-main-context p {
	color: #585858;
	display: block;
	margin-block-start: 0em !important;
	margin-block-end: 0em !important;
	margin-inline-start: 0px !important;
	margin-inline-end: 0px !important;
}

.wf-main-context p>img {
	max-width: 100%;
}

/**
超宽度换行
**/
.el-tag {
	white-space: normal !important;
	;
	height: auto !important;
	;
}</style>
